package com.appspot.autopartymanager.controller.cron;

import java.util.Properties;

import javax.mail.Address;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

public class MailsendController extends Controller {
    private static Logger logger = LoggerFactory.getLogger(MailsendController.class);

    @Override
    public Navigation run() throws Exception {
        Session session = Session.getDefaultInstance(new Properties());
        logger.info("created session.");
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress("admin@auto-party-manager.appspotmail.com"));
        message.setRecipients(RecipientType.TO, new Address[]{
//            new InternetAddress("vicissi@gmail.com")
        });
        message.setSubject("こんにちはこんにちは！", "ISO-2022-JP");
        message.setText("こんにちはー");
        Transport.send(message);
        logger.info("sent.");
        
        return null;
    }
}
